package com.controller;

import com.Service.ListingService;
import com.Service.MedicalCardService;
import com.model.pojo.Buildcard;
import com.model.pojo.Listing;
import com.model.pojo.MedicalCard;
import com.sun.scenario.effect.impl.sw.sse.SSEBlend_SRC_OUTPeer;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import javax.smartcardio.Card;
import java.util.List;

@Controller
@RequestMapping("Listing")
public class ListingController {
    @Resource
    public ListingService listingService;
    @Resource
    public MedicalCardService medicalCardService;
    @Resource
    public Buildcard buildcard;



    @RequestMapping("Listing")
    public String listMessage(HttpSession session, HttpServletRequest request) {

//        List<Listing> list= listingService.listMessage();
        String card = request.getParameter("card");//获取卡号
        List<Listing> Listting = null;
        if (card != null) {
            String[] num = request.getParameterValues("check");  //获取被选中的复选框值
            for (int i = 0; i < num.length; i++) {

                Listting = listingService.listOf(card, num[i]); //将卡号和复选框值穿走

            }
        } else {
            Listting = listingService.listOf("", "");

        }

        if (Listting != null) {
            session.setAttribute("Listting", Listting);
            return "Listting";
        } else {//需改
            return "Listting";
        }
    }


    @RequestMapping("listOfPayCost")
    public String listOfPayCost(HttpSession session, HttpServletRequest request, String listingSerialNumber) {


        List<Listing> listtingList = listingService.personalMessage(listingSerialNumber);

        if (listtingList != null) {
            session.setAttribute("listtingList", listtingList);

            return "listtingList";
        } else {//需改

            return "listtingList";
        }
    }


}
